<template>
    <view>

        <view class="head">
            <view class="info">
                <view class="user">
                    <image v-if="flag=='phone'" :src="info.avatar_text" alt=""> </image>
                    <image v-if="flag=='wechat'" :src="info.userhead" alt=""> </image>
                    <view class="name">
                        <text v-if="flag=='phone'">
                            {{info.mobile_text}}
                        </text>
                    <text v-if="flag=='wechat'">{{info.nickname}}</text>
                    <text>ID: {{info.id}}</text>
                </view>
                </view>
                <view class="btn">分享店铺</view>
            </view>
        </view>
        <view class="menu-box">
            <view class="region">
                <view class="title">{{ info.store_text }}</view>
                <view class="menu-row">
                    <view class="cell">
                        <view class="count">122</view>
                        <view class="name">今日访客</view>
                    </view>
                    <view class="cell">
                        <view class="count">23</view>
                        <view class="name">今日订单</view>
                    </view>
                    <view class="cell">
                        <view class="count">888</view>
                        <view class="name">今日收入</view>
                    </view>
                </view>
            </view>
            <view class="region">
                <view class="title">常用操作</view>
                <view class="menu-row">
                    <view class="cell" @click="order">
                        <view class="count">12</view>
                        <view class="name">全部订单</view>
                    </view>
                    <view class="cell" @click="daiqian">
                        <view class="count">33</view>
                        <view class="name">待签署订单</view>
                    </view>

                    <view class="cell" @click="yiqian">
                        <view class="count">53</view>
                        <view class="name">待送检订单</view>
                    </view>
                </view>
            </view>
            <view class="region1">
                <view class="menu-row">
                    <view class="cell" @click="daicheck">
                        <view class="count">54</view>
                        <view class="name">检测中</view>
                    </view>
                    <view class="cell" @click="yicheck">
                        <view class="count">2</view>
                        <view class="name">待入库</view>
                    </view>
                    <view class="cell" @click="waitingpay">
                        <view class="count">2</view>
                        <view class="name">待打款</view>
                    </view>




                </view>
                <view class="menu-row">
                    <view class="cell" @click="payed">
                        <view class="count">54</view>
                        <view class="name">到款状况</view>
                    </view>
                    <view class="cell" @click="ydz">
                        <view class="count">54</view>
                        <view class="name">已到账</view>
                    </view>

                    <view class="cell" @click="uploadProductOrder">
                        <view class="count" style="color:#ff7962;font-weight:1000;">＋</view>
                        <view class="name">上传产品</view>
                    </view>


                </view>
            </view>


        </view>
        <u-toast ref="notice"></u-toast>

    </view>
</template>
<script>
export default {
    onLoad(option) {
        console.log(option)
        this.id = option.id ? option.id : "",
        this.phone = option.phone ? option.phone : "",
        this.flag = option.flag ? option.flag : ""
        this.getinfo()


    },
    onShow()
    {
        let merchant = uni.getStorageSync("merchantinfo")
        if(merchant && JSON.stringify(merchant) != "{}")
			{
				this.info = merchant
			}

    },
    data() {
        return {
            id: "",
            flag:"",
            phone:"",
            info:{}

        }
    },
    methods: {

        async getinfo() {
            let data = {
                empid: this.id
            }

            let result = await this.$u.api.admin.nowemployee(data)
            if (result.code) {
                this.info = result.data
                uni.setStorageSync('merchantinfo', this.info);
            } else {
                this.$refs.notice.show({
                    type: "error",
                    message: result.msg,
                    duration: 1200,
                    complete: () => {
                        //返回上一个界面
                        uni.$u.route({
                            type: "navigateBack",
                            delta: 1,
                        });
                    }
                })
            }
        },
        // 上传产品订单
        uploadProductOrder() {
            uni.$u.route({
                url: "pagesB/merchant/addorder",

            })
        },
        order() {
            uni.$u.route({
                url: "pagesB/merchant/order"
            })
        },
        yicheck() {
            uni.$u.route({
                url: "pagesB/merchant/yicheck"
            })

        },
        // 待检订单
        daiqian() {
            uni.$u.route({
                url: "pagesB/merchant/daiqian"
            })
        },
        // 待检
        daicheck() {
            uni.$u.route({
                url: "pagesB/merchant/daijian"
            })
        },
        // 待打款
        waitingpay() {
            uni.$u.route({
                url: "pagesB/merchant/waitingpay"
            })
        },
        // 已打款
        payed() {
            uni.$u.route({
                url: "pagesB/merchant/payed"
            })
        },
        // 已到账
        ydz() {
            uni.$u.route({
                url: "pagesB/merchant/ydz"
            })
        },
        yiqian() {
            uni.$u.route({
                url: "pagesB/merchant/yiqian"
            })
        }

    }
}
</script>
    
<style lang="scss">
page {
    background-color: #f8f8f8;
}

.head {
    position: relative;
    width: 100%;
    height: 400rpx;
    background-color: #ff7962;
}

.head .info {
    padding-top: 150rpx;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.head .info .user {
    padding-left: 50rpx;
    display: flex;
    justify-content: center;
    align-items: center;
}

.head .info .user image {
    width: 120rpx;
    height: 120rpx;
}

.head .info .user .name {
    padding-left: 20rpx;
    font-size: 28rpx;
    font-weight: 600;
    color: #FFFFFF;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-direction: column;
}

.head .info .user .name text {
    line-height: 40rpx;
}

.head .info .btn {
    text-align: center;
    background-color: #ff907c;
    color: #FFFFFF;
    font-size: 30rpx;
    width: 200rpx;
    height: 80rpx;
    line-height: 80rpx;
    border-top-left-radius: 10rpx;
    border-bottom-left-radius: 10rpx;
}

.menu-box {
    position: absolute;
    top: 300rpx;
    width: 100%;
}

.region {
    background-color: #FFFFFF;
    margin: 30rpx;
    border-radius: 10rpx;
}

.region .title {
    font-size: 32rpx;
    font-weight: bold;
    padding: 30rpx;
}

.region .menu-row {
    display: flex;
    justify-content: center;
    align-items: center;
}

.region .menu-row .cell {
    width: 30%;
    height: 200rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.region .menu-row .cell .count {
    font-size: 40rpx;
}

.region .menu-row .cell .name {
    font-size: 30rpx;
    line-height: 100rpx;
    color: #8a8a8a;
}



.region1 {
    background-color: #FFFFFF;
    margin: 10rpx 30rpx;
    border-radius: 10rpx;
}

.region1 .title {
    font-size: 32rpx;
    font-weight: bold;
    padding: 30rpx;
}

.region1 .menu-row {
    display: flex;
    margin-top: -19px;
    justify-content: center;
    align-items: center;
}

.region1 .menu-row .cell {
    width: 30%;
    height: 200rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.region1 .menu-row .cell .count {
    font-size: 40rpx;
}

.region1 .menu-row .cell .name {
    font-size: 30rpx;
    line-height: 100rpx;
    color: #8a8a8a;
}
</style>